public class Solution {
    public boolean isSymmetric(TreeNode root) {
        return isSymmetricChild(root.left,root.right);
    }
    public boolean isSymmetricChild(TreeNode left,TreeNode right){
        if (left == null && right != null || left != null && right == null){
            return false;
        }
        if (left == null && right == null){
            return true;
        }
        if(left.val != right.val) return false;
        return isSymmetricChild(left.left,right.right) && isSymmetricChild(left.right,right.left);
    }
}